package com.jl.jlapp.mvp.fragment;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.RecyclerView;
import android.text.TextPaint;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import butterknife.BindView;
import butterknife.ButterKnife;

import com.jl.jlapp.R;
import com.jl.jlapp.adapter.GoodsMsgActivityAdapter;
import com.jl.jlapp.adapter.GoodsMsgEvaluationAdapter;
import com.jl.jlapp.adapter.GoodsMsgEvaluationAdapter.OnClickGoodsPicItemListener;
import com.jl.jlapp.eneity.Goods;
import com.jl.jlapp.eneity.GoodsDetailModel;
import com.jl.jlapp.eneity.GoodsDetailModel.ResultDataBean;
import com.jl.jlapp.eneity.GoodsDetailModel.ResultDataBean.GoodsActivitysBean;
import com.jl.jlapp.eneity.GoodsDetailModel.ResultDataBean.GoodsActivitysBean.ActivityInformationBean;
import com.jl.jlapp.eneity.GoodsDetailModel.ResultDataBean.GoodsEvaluationsBean;
import com.jl.jlapp.eneity.GoodsDetailModel.ResultDataBean.GoodsEvaluationsBean.UserBean;
import com.jl.jlapp.eneity.GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean;
import com.jl.jlapp.eneity.GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean.GoodsDisplayPicturesBean;
import com.jl.jlapp.eneity.PostModel;
import com.jl.jlapp.eneity.ShipAddressModel;
import com.jl.jlapp.mvp.activity.ChooseAddressActivity;
import com.jl.jlapp.mvp.activity.ChooseAddressActivity.OnClicktem;
import com.jl.jlapp.mvp.activity.GoodsDetailActivity;
import com.jl.jlapp.mvp.activity.LoginActivity;
import com.jl.jlapp.mvp.activity.OrderSubmitActivity;
import com.jl.jlapp.mvp.activity.PhotoViewActivity;
import com.jl.jlapp.nets.Api;
import com.jl.jlapp.nets.CommonObserver;
import com.jl.jlapp.nets.Net;
import com.jl.jlapp.nets.Transformer;
import com.jl.jlapp.popu.ChooseGoodsSpecPopu;
import com.jl.jlapp.popu.ChooseGoodsSpecPopu.OnClickAddShopCartBtnListener;
import com.jl.jlapp.popu.ChooseGoodsSpecPopu.OnClickBuyNowBtnListener;
import com.jl.jlapp.popu.ChooseGoodsSpecPopu.OnClickGoodsSpecItemListener;
import com.jl.jlapp.popu.ChooseSendToAddressPopu;
import com.jl.jlapp.popu.ChooseSendToAddressPopu.OnClickItem;
import com.jl.jlapp.popu.ChooseSendToAddressPopu.setOnClickBottomOKBtn;
import com.jl.jlapp.utils.CustomLanearLayoutManager;
import com.jl.jlapp.utils.loader.GlideImageLoader;
import com.youth.banner.Banner;

import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

public class GoodsMsgFragment extends Fragment implements OnClickListener, ChooseSendToAddressPopu.OnClickItem, ChooseSendToAddressPopu.setOnClickBottomOKBtn, ChooseGoodsSpecPopu.OnClickBuyNowBtnListener, ChooseGoodsSpecPopu.OnClickAddShopCartBtnListener, ChooseGoodsSpecPopu.OnClickGoodsSpecItemListener, OnClicktem, OnClickGoodsPicItemListener {
    public static final String TAG = "GoodsMsgFragment";
    @BindView(R.id.layout_activityForNotPreSell)
    RelativeLayout activityForNotPreSell;
    @BindView(R.id.layout_activityForPreSell)
    RelativeLayout activityForPreSell;
    Integer activityId;
    List activityList;
    String activityName;
    @BindView(R.id.text_activityNameAndDate)
    TextView activityNameAndDate;
    String chooseAddress = "";
    ChooseGoodsSpecPopu chooseGoodsSpecPopu;
    ChooseSendToAddressPopu chooseSendToAddressPopu;
    double compositeScores = 0.0D;
    int discrepancyEvalNum = 0;
    List<GoodsDetailModel.ResultDataBean.GoodsEvaluationsBean> evaluationList;
    double goodEvalNum = 0.0D;
    Double goodEvaluationRating = Double.valueOf(0.0D);
    @BindView(R.id.goods_banner)
    Banner goodsBanner;
    GoodsDetailActivity goodsDetailActivity;
    GoodsDetailModel.ResultDataBean goodsDetailDataBean;
    @BindView(R.id.goods_evaluation_high_praise)
    TextView goodsEvaluationHighPraise;
    @BindView(R.id.goods_evaluation_num)
    TextView goodsEvaluationNum;
    Integer goodsId = Integer.valueOf(0);
    GoodsMsgActivityAdapter goodsMsgActivityAdapter;
    @BindView(R.id.goods_msg_activity_recycler_view)
    RecyclerView goodsMsgActivityRecyclerView;
    @BindView(R.id.goods_msg_checked_look_all_evaluation)
    TextView goodsMsgCheckedLookAllEvaluation;
    @BindView(R.id.goods_msg_checked_look_detail)
    LinearLayout goodsMsgCheckedLookDetail;
    @BindView(R.id.goods_msg_choose_send_address)
    TextView goodsMsgChooseSendAddress;
    @BindView(R.id.goods_msg_choose_spec_btn)
    ImageView goodsMsgChooseSpecBtn;
    GoodsMsgEvaluationAdapter goodsMsgEvaluationAdapter;
    @BindView(R.id.goods_msg_evaluation)
    RecyclerView goodsMsgEvaluationRecyclerView;
    @BindView(R.id.goods_msg_goods_name)
    TextView goodsMsgGoodsName;
    @BindView(R.id.goods_msg_goods_price)
    TextView goodsMsgGoodsPrice;
    @BindView(R.id.goods_msg_goods_spec_detail)
    TextView goodsMsgGoodsSpecDetail;
    @BindView(R.id.goods_msg_introduction)
    TextView goodsMsgIntroduction;
    @BindView(R.id.goods_msg_old_goods_price)
    TextView goodsMsgOldGoodsPrice;
    int hasPicNum = 0;
    List images;
    @BindView(R.id.is_saled_goods_num)
    TextView isSaledGoodsNum;
    int middleEvalNum = 0;
    private ProgressDialog progressDialog;
    @BindView(R.id.send_to_round_gray_three)
    ImageView sendToRoundGrayThree;
    List<ShipAddressModel.ResultDataBean> shipAddressResultDataBeans;
    int userId = 0;
    View view;
    WebView webView;

    private void getHasStrockGoods() {
        ArrayList<GoodsSpecificationDetailsBean> localArrayList = new ArrayList();
        int i = 0;
        while (i < this.goodsDetailDataBean.getGoodsSpecificationDetails().size()) {
            if ((this.goodsDetailDataBean.getZeroStock() == 0) && (((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) this.goodsDetailDataBean.getGoodsSpecificationDetails().get(i)).getGxcGoodsState() == 2) && (((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) this.goodsDetailDataBean.getGoodsSpecificationDetails().get(i)).getGxcGoodsStock() <= 0)) {
                localArrayList.add(this.goodsDetailDataBean.getGoodsSpecificationDetails().get(i));
            }
            i += 1;
        }
        if (localArrayList.size() > 0) {
            i = 0;
            if (i < this.goodsDetailDataBean.getGoodsSpecificationDetails().size()) {
                int j = 0;
                for (; ; ) {
                    int k = i;
                    if (j < localArrayList.size()) {
                        if (((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) this.goodsDetailDataBean.getGoodsSpecificationDetails().get(i)).getId() == ((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) localArrayList.get(j)).getId()) {
                            this.goodsDetailDataBean.getGoodsSpecificationDetails().remove(i);
                            this.goodsDetailDataBean.getGoodsSpecificationDetails().add(localArrayList.get(j));
                            localArrayList.remove(j);
                            k = i - 1;
                        }
                    } else {
                        i = k + 1;
                        break;
                    }
                    j += 1;
                }
            }
        }
    }

    private void initBanner(List<GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean> paramList, int paramInt) {
        this.images = new ArrayList();
        if (paramList.size() > 0) {
            int i = 0;
            while (i < ((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) paramList.get(paramInt)).getGoodsDisplayPictures().size()) {
                this.images.add("http://117.158.178.202:8001/JLMIS/" + ((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean.GoodsDisplayPicturesBean) ((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) paramList.get(paramInt)).getGoodsDisplayPictures().get(i)).getPicUrl());
                i += 1;
            }
            if (this.images.size() == 0) {
                this.images.add(Integer.valueOf(2131165505));
            }
        } else {
            this.goodsBanner.setImageLoader(new GlideImageLoader());
            this.goodsBanner.setImages(this.images);
            this.goodsBanner.setIndicatorGravity(7);
            this.goodsBanner.start();
            Toast.makeText(getContext(), "数据错误，暂无规格。", Toast.LENGTH_SHORT).show();
        }
    }

    private void setGoodsEvaluationAdapter(GoodsDetailModel.ResultDataBean paramResultDataBean) {
        this.evaluationList = new ArrayList();
        this.goodEvaluationRating = Double.valueOf(0.0D);
        this.goodEvalNum = 0.0D;
        this.middleEvalNum = 0;
        this.discrepancyEvalNum = 0;
        this.hasPicNum = 0;
        if (paramResultDataBean.getGoodsEvaluations().size() > 0) {
            this.goodsMsgCheckedLookAllEvaluation.setVisibility(View.VISIBLE);
            double d1 = 0.0D;
            int i = 0;
            if (i < paramResultDataBean.getGoodsEvaluations().size()) {
                d1 += ((GoodsDetailModel.ResultDataBean.GoodsEvaluationsBean) paramResultDataBean.getGoodsEvaluations().get(i)).getScore();
                if ((((GoodsDetailModel.ResultDataBean.GoodsEvaluationsBean) paramResultDataBean.getGoodsEvaluations().get(i)).getScore() >= 4.0D) && (((GoodsDetailModel.ResultDataBean.GoodsEvaluationsBean) paramResultDataBean.getGoodsEvaluations().get(i)).getScore() <= 5.0D)) {
                    this.goodEvalNum += 1.0D;
                } else {
                    if (((GoodsDetailModel.ResultDataBean.GoodsEvaluationsBean) paramResultDataBean.getGoodsEvaluations().get(i)).getEvaluationPics().size() > 0) {
                        this.hasPicNum += 1;
                    }
                    i += 1;
                    if ((((GoodsDetailModel.ResultDataBean.GoodsEvaluationsBean) paramResultDataBean.getGoodsEvaluations().get(i)).getScore() >= 2.0D) && (((GoodsDetailModel.ResultDataBean.GoodsEvaluationsBean) paramResultDataBean.getGoodsEvaluations().get(i)).getScore() < 4.0D)) {
                        this.middleEvalNum += 1;
                    } else {
                        this.discrepancyEvalNum += 1;
                    }
                }
            }
            Log.d("aaaaaaaa", "goodEvalNum:" + this.goodEvalNum);
            ArrayList<GoodsEvaluationsBean> localArrayList1;
            ArrayList<GoodsEvaluationsBean> localArrayList2;
            ArrayList<GoodsEvaluationsBean> localArrayList3;
            ArrayList<GoodsEvaluationsBean> localArrayList4;
            localArrayList1 = new ArrayList();
            localArrayList2 = new ArrayList();
            localArrayList3 = new ArrayList();
            localArrayList4 = new ArrayList();
            if (this.goodEvalNum != 0.0D) {
                double d2 = this.goodEvalNum / paramResultDataBean.getGoodsEvaluations().size();
                double d3 = new BigDecimal(d2).setScale(4, 4).doubleValue();
                this.goodEvaluationRating = Double.valueOf(100.0D * d3);
                Log.d("aaaaaaaa", "好评人数：" + this.goodEvalNum + " goodEvaluationValue:" + d2 + " 好评率：" + d3 + "  goodEvaluationRating:" + this.goodEvaluationRating);
                this.goodsDetailActivity.goodEvalNum = Integer.valueOf((int) this.goodEvalNum);
                this.goodsDetailActivity.middleEvalNum = Integer.valueOf(this.middleEvalNum);
                this.goodsDetailActivity.discrepancyEvalNum = Integer.valueOf(this.discrepancyEvalNum);
                this.goodsDetailActivity.goodEvaluationRating = this.goodEvaluationRating;
                this.goodsDetailActivity.hasPicNum = Integer.valueOf(this.hasPicNum);
                if (d1 != 0.0D) {
                    this.compositeScores = new BigDecimal(d1 / paramResultDataBean.getGoodsEvaluations().size()).setScale(1, 4).doubleValue();
                    this.goodsDetailActivity.compositeScores = this.compositeScores;
                }
                this.goodsEvaluationHighPraise.setText(this.goodEvaluationRating + "");
                i = 0;
                if (i >= paramResultDataBean.getGoodsEvaluations().size()) {
                    return;
                }
                if ((((GoodsDetailModel.ResultDataBean.GoodsEvaluationsBean) paramResultDataBean.getGoodsEvaluations().get(i)).getUser().getPhone() != null) && (((GoodsDetailModel.ResultDataBean.GoodsEvaluationsBean) paramResultDataBean.getGoodsEvaluations().get(i)).getUser().getPhone().length() == 11)) {
                    String str = ((GoodsDetailModel.ResultDataBean.GoodsEvaluationsBean) paramResultDataBean.getGoodsEvaluations().get(i)).getUser().getPhone();
                    ((GoodsDetailModel.ResultDataBean.GoodsEvaluationsBean) paramResultDataBean.getGoodsEvaluations().get(i)).getUser().setPhone(replacePhoneNum(str));
                }
                if ((((GoodsDetailModel.ResultDataBean.GoodsEvaluationsBean) paramResultDataBean.getGoodsEvaluations().get(i)).getScore() < 4.0D) || (((GoodsDetailModel.ResultDataBean.GoodsEvaluationsBean) paramResultDataBean.getGoodsEvaluations().get(i)).getScore() > 5.0D) || (((GoodsDetailModel.ResultDataBean.GoodsEvaluationsBean) paramResultDataBean.getGoodsEvaluations().get(i)).getEvaluationPics().size() <= 0)) {
                    return;
                }
                localArrayList1.add(paramResultDataBean.getGoodsEvaluations().get(i));
            } else {
                i += 1;
                if (this.middleEvalNum != 0) {
                    Log.d("aaaaaaaa", "好评人数：" + this.goodEvalNum + " goodEvaluationValue:" + 0 + " 好评率：" + 0 + "  goodEvaluationRating:" + 0);
                    this.goodsDetailActivity.goodEvalNum = Integer.valueOf((int) this.goodEvalNum);
                    this.goodsDetailActivity.middleEvalNum = Integer.valueOf(this.middleEvalNum);
                    this.goodsDetailActivity.discrepancyEvalNum = Integer.valueOf(this.discrepancyEvalNum);
                    this.goodsDetailActivity.goodEvaluationRating = this.goodEvaluationRating;
                    this.goodsDetailActivity.hasPicNum = Integer.valueOf(this.hasPicNum);
                    if (d1 == 0.0D) {
                        return;
                    }
                    this.compositeScores = new BigDecimal(d1 / paramResultDataBean.getGoodsEvaluations().size()).setScale(1, 4).doubleValue();
                    this.goodsDetailActivity.compositeScores = this.compositeScores;
                }
                Log.d("aaaaaaaa", "好评人数：" + this.goodEvalNum + " goodEvaluationValue:" + 0 + " 好评率：" + 0 + "  goodEvaluationRating:" + 0);
                this.goodsDetailActivity.goodEvalNum = Integer.valueOf((int) this.goodEvalNum);
                this.goodsDetailActivity.middleEvalNum = Integer.valueOf(this.middleEvalNum);
                this.goodsDetailActivity.discrepancyEvalNum = Integer.valueOf(this.discrepancyEvalNum);
                this.goodsDetailActivity.goodEvaluationRating = this.goodEvaluationRating;
                this.goodsDetailActivity.hasPicNum = Integer.valueOf(this.hasPicNum);
                if (d1 == 0.0D) {
                    return;
                }
                this.compositeScores = new BigDecimal(d1 / paramResultDataBean.getGoodsEvaluations().size()).setScale(1, 4).doubleValue();
                this.goodsDetailActivity.compositeScores = this.compositeScores;
                if ((((GoodsDetailModel.ResultDataBean.GoodsEvaluationsBean) paramResultDataBean.getGoodsEvaluations().get(i)).getScore() >= 4.0D) && (((GoodsDetailModel.ResultDataBean.GoodsEvaluationsBean) paramResultDataBean.getGoodsEvaluations().get(i)).getScore() <= 5.0D) && (((GoodsDetailModel.ResultDataBean.GoodsEvaluationsBean) paramResultDataBean.getGoodsEvaluations().get(i)).getEvaluationPics().size() <= 0)) {
                    localArrayList2.add(paramResultDataBean.getGoodsEvaluations().get(i));
                } else if (((GoodsDetailModel.ResultDataBean.GoodsEvaluationsBean) paramResultDataBean.getGoodsEvaluations().get(i)).getEvaluationPics().size() > 0) {
                    localArrayList3.add(paramResultDataBean.getGoodsEvaluations().get(i));
                } else {
                    localArrayList4.add(paramResultDataBean.getGoodsEvaluations().get(i));
                }
            }
            if (localArrayList1.size() >= 3) {
                i = 0;
                while (i < 3) {
                    this.evaluationList.add(localArrayList1.get(i));
                    i += 1;
                }
            }
            i = 0;
            while (i < localArrayList1.size()) {
                this.evaluationList.add(localArrayList1.get(i));
                i += 1;
            }
            if (localArrayList2.size() >= 3 - this.evaluationList.size()) {
                i = 0;
                while (i < 3 - this.evaluationList.size()) {
                    this.evaluationList.add(localArrayList2.get(i));
                    i += 1;
                }
            }
            i = 0;
            while (i < localArrayList2.size()) {
                this.evaluationList.add(localArrayList2.get(i));
                i += 1;
            }
            if (localArrayList3.size() >= 3 - this.evaluationList.size()) {
                i = 0;
                while (i < 3 - localArrayList1.size()) {
                    this.evaluationList.add(localArrayList3.get(i));
                    i += 1;
                }
            }
            i = 0;
            while (i < localArrayList3.size()) {
                this.evaluationList.add(localArrayList3.get(i));
                i += 1;
            }
            if (localArrayList4.size() >= 3 - this.evaluationList.size()) {
                i = 0;
                while (i < 3 - localArrayList1.size()) {
                    this.evaluationList.add(localArrayList4.get(i));
                    i += 1;
                }
            }
            i = 0;
            while (i < localArrayList4.size()) {
                this.evaluationList.add(localArrayList4.get(i));
                i += 1;
            }
        }
        this.goodsMsgCheckedLookAllEvaluation.setVisibility(View.GONE);
        this.goodsMsgEvaluationRecyclerView.setLayoutManager(new CustomLanearLayoutManager(getActivity(), false));
        this.goodsMsgEvaluationAdapter = new GoodsMsgEvaluationAdapter(2131361955, this.evaluationList);
        this.goodsMsgEvaluationAdapter.setOnClickGoodsPicItemListener(this);
        this.goodsMsgEvaluationRecyclerView.setAdapter(this.goodsMsgEvaluationAdapter);
    }

    public void OnClickAddShopCartBtn(String paramString, Integer paramInteger1, Integer paramInteger2) {
        this.chooseGoodsSpecPopu.dismiss();
        this.goodsMsgGoodsSpecDetail.setText(paramString);
        this.goodsDetailActivity.goodsSpecificationId = paramInteger1;
        Log.d("GoodsMsgFragment", "num:" + paramInteger2);
        if (this.userId > 0) {
            insertShoppingCart(Integer.valueOf(this.userId), this.goodsId, paramInteger1, paramInteger2, this.activityId, this.activityName);
            return;
        }
        Toast.makeText(getContext(), "您还未登录，请先登录。", Toast.LENGTH_SHORT).show();
        startActivity(new Intent(getContext(), LoginActivity.class));
    }

    public void OnClickBuyNowBtn(String paramString, Integer paramInteger1, Integer paramInteger2, Integer paramInteger3) {
        if (this.userId > 0) {
            Intent intent = new Intent(getActivity(), OrderSubmitActivity.class);
            intent.putExtra("isFromWhichPage", 1);
            intent.putExtra("buyNum", paramInteger2);
            intent.putExtra("goodsSpecId", paramInteger1);
            intent.putExtra("goodsId", this.goodsId);
            intent.putExtra("isPresell", paramInteger3);
            if (paramInteger3.intValue() == 1) {
                intent.putExtra("activityId", this.activityId);
            }
            startActivity(intent);
            this.chooseGoodsSpecPopu.dismiss();
            return;
        }
        Toast.makeText(getContext(), "您还未登录，请先登录。", Toast.LENGTH_SHORT).show();
        startActivity(new Intent(getContext(), LoginActivity.class));
    }

    public void OnClickGoodsPicItem(String paramString) {
        Intent localIntent = new Intent(getActivity(), PhotoViewActivity.class);
        localIntent.putExtra("picUrl", paramString);
        startActivity(localIntent);
    }

    public void OnClickGoodsSpecItem(String paramString, Integer paramInteger1, Integer paramInteger2) {
        initBanner(this.goodsDetailActivity.resultDataBeanMsg.getGoodsSpecificationDetails(), paramInteger2.intValue());
        setGoodsActivityAdapter(this.goodsDetailActivity.resultDataBeanMsg, paramInteger2.intValue());
        this.goodsMsgGoodsSpecDetail.setText(paramString);
        this.goodsDetailActivity.goodsSpecificationId = paramInteger1;
        this.goodsMsgGoodsPrice.setText(((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) this.goodsDetailActivity.resultDataBeanMsg.getGoodsSpecificationDetails().get(paramInteger2.intValue())).getPrice() + "");
        if (((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) this.goodsDetailActivity.resultDataBeanMsg.getGoodsSpecificationDetails().get(paramInteger2.intValue())).getOldPrice() > 0.0D) {
            this.goodsMsgOldGoodsPrice.setVisibility(View.VISIBLE);
            this.goodsMsgOldGoodsPrice.setText("¥" + ((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) this.goodsDetailActivity.resultDataBeanMsg.getGoodsSpecificationDetails().get(paramInteger2.intValue())).getOldPrice() + "");
        } else {
            this.goodsMsgOldGoodsPrice.getPaint().setFlags(16);
            this.goodsMsgOldGoodsPrice.setVisibility(View.GONE);
        }
    }

    public void buildProgressDialog() {
        if (this.progressDialog == null) {
            this.progressDialog = new ProgressDialog(getContext());
            this.progressDialog.setProgressStyle(0);
        }
        this.progressDialog.setMessage("加载中");
        this.progressDialog.setCancelable(true);
        this.progressDialog.show();
    }

    public void cancelProgressDialog() {
        if ((this.progressDialog != null) && (this.progressDialog.isShowing())) {
            this.progressDialog.dismiss();
        }
    }

    public void getDataToControl(GoodsDetailModel.ResultDataBean paramResultDataBean) {
        initBanner(paramResultDataBean.getGoodsSpecificationDetails(), 0);
        this.goodsMsgGoodsName.setText(paramResultDataBean.getName());
        this.goodsMsgIntroduction.setText(paramResultDataBean.getIntrodution());
        if (paramResultDataBean.getGoodsSpecificationDetails().size() > 0) {
            this.goodsMsgChooseSpecBtn.setVisibility(View.VISIBLE);
            this.goodsMsgGoodsSpecDetail.setText(((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) paramResultDataBean.getGoodsSpecificationDetails().get(0)).getSpecifications());
            this.goodsMsgGoodsPrice.setText(((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) paramResultDataBean.getGoodsSpecificationDetails().get(0)).getPrice() + "");
            if (((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) paramResultDataBean.getGoodsSpecificationDetails().get(0)).getOldPrice() > 0.0D) {
                this.goodsMsgOldGoodsPrice.setVisibility(View.VISIBLE);
                this.goodsMsgOldGoodsPrice.setText("¥" + ((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) paramResultDataBean.getGoodsSpecificationDetails().get(0)).getOldPrice());
                this.goodsMsgOldGoodsPrice.getPaint().setFlags(16);
                this.goodsDetailActivity.goodsSpecificationId = Integer.valueOf(((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) paramResultDataBean.getGoodsSpecificationDetails().get(0)).getId());
            }
        } else {
            this.isSaledGoodsNum.setText(paramResultDataBean.getSaleCount() + "");
            if (((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) paramResultDataBean.getGoodsSpecificationDetails().get(0)).getGxcGoodsState() != 1) {
                return;
            }
            this.activityForPreSell.setVisibility(View.VISIBLE);
            this.activityForNotPreSell.setVisibility(View.GONE);
            int i = 0;
            while (i < paramResultDataBean.getGoodsActivitysX().size()) {
                if (this.activityId.intValue() == ((GoodsDetailModel.ResultDataBean.GoodsActivitysBean) paramResultDataBean.getGoodsActivitysX().get(i)).getActivityInformation().getIdX()) {
                    String str1 = ((GoodsDetailModel.ResultDataBean.GoodsActivitysBean) paramResultDataBean.getGoodsActivitysX().get(i)).getActivityInformation().getNameX();
                    Object localObject = new SimpleDateFormat("yyyy-MM-dd");
                    String str2 = ((SimpleDateFormat) localObject).format(Long.valueOf(((GoodsDetailModel.ResultDataBean.GoodsActivitysBean) paramResultDataBean.getGoodsActivitysX().get(i)).getActivityInformation().getBeginValidityTime()));
                    localObject = ((SimpleDateFormat) localObject).format(Long.valueOf(((GoodsDetailModel.ResultDataBean.GoodsActivitysBean) paramResultDataBean.getGoodsActivitysX().get(i)).getActivityInformation().getEndValidityTime()));
                    this.activityNameAndDate.setText(str1 + "(" + str2 + "~" + (String) localObject + ")");
                }
                i += 1;
            }
            this.goodsMsgOldGoodsPrice.setVisibility(View.GONE);
            this.goodsMsgChooseSpecBtn.setVisibility(View.GONE);
            this.goodsMsgGoodsSpecDetail.setText("暂无规格");
            Toast.makeText(getContext(), "数据错误，暂无规格。", Toast.LENGTH_SHORT).show();
        }
        this.activityForPreSell.setVisibility(View.GONE);
        this.activityForNotPreSell.setVisibility(View.VISIBLE);
        setGoodsActivityAdapter(paramResultDataBean, 0);
        this.goodsEvaluationNum.setText(paramResultDataBean.getGoodsEvaluations().size() + "");
        setGoodsEvaluationAdapter(paramResultDataBean);
    }

    public void getGoodsDetailMsgByGoodsId() {
        Net.get().getGoodsDetailMsgByGoodsId(this.goodsId.intValue())
                .compose(Transformer.<GoodsDetailModel>switchSchedulers())
                .subscribe(new CommonObserver<GoodsDetailModel>() {

                    @Override
                    protected void onError(String errorMsg) {

                    }

                    @Override
                    protected void onSuccess(GoodsDetailModel goodsDetailModel) {

                    }
                });
    }

    public void getShippingAddressByUserId() {
        Net.get().getShippingAddressByUserId(this.userId)
                .compose(Transformer.<ShipAddressModel>switchSchedulers())
                .subscribe(new CommonObserver<ShipAddressModel>() {
                    @Override
                    protected void onError(String errorMsg) {

                    }

                    @Override
                    protected void onSuccess(ShipAddressModel shipAddressModel) {

                    }
                });
    }

    public void insertShoppingCart(Integer paramInteger1, Integer paramInteger2, Integer paramInteger3, Integer paramInteger4, Integer paramInteger5, String paramString) {
        Net.get().insertShoppingCart(paramInteger1.intValue(), paramInteger2.intValue(), paramInteger3.intValue(), paramInteger4.intValue(), paramInteger5.intValue(), paramString)
                .compose(Transformer.<PostModel>switchSchedulers())
                .subscribe(new CommonObserver<PostModel>() {
                    @Override
                    protected void onError(String errorMsg) {

                    }

                    @Override
                    protected void onSuccess(PostModel postModel) {

                    }
                });

    }

    public void onAttach(Activity paramActivity) {
        super.onAttach(paramActivity);
        this.goodsDetailActivity = ((GoodsDetailActivity) getActivity());
        this.goodsId = this.goodsDetailActivity.goodsId;
        this.activityId = this.goodsDetailActivity.activityId;
        this.activityName = this.goodsDetailActivity.activityName;
    }

    public void onClick(View paramView) {

        Log.d("aaaaaaaaa", "我点击了按钮");
        this.chooseGoodsSpecPopu = new ChooseGoodsSpecPopu(getActivity(), this.goodsMsgGoodsSpecDetail.getText().toString().trim(), Integer.valueOf(0), this.goodsDetailDataBean);
        this.chooseGoodsSpecPopu.showAtLocation(getActivity().findViewById(R.id.goods_msg_page), 80, 0, 0);
        setChooseGoodsSpecPopuListener();
        this.chooseSendToAddressPopu = new ChooseSendToAddressPopu(getActivity(), this.goodsMsgChooseSendAddress.getText().toString().trim(), this.shipAddressResultDataBeans);
        this.chooseSendToAddressPopu.showAtLocation(getActivity().findViewById(R.id.goods_msg_page), 80, 0, 0);
        setChooseAddressPopuListener();
        this.goodsDetailActivity.onClickLookGoodsSpec();
        this.goodsDetailActivity.onClickLookEvaluation();
    }

    public void onClickBottomOkBtn() {
        this.chooseSendToAddressPopu.dismiss();
        ChooseAddressActivity.setOnClicktem(this);
        Intent localIntent = new Intent(getActivity(), ChooseAddressActivity.class);
        localIntent.putExtra("whichPage", 1);
        startActivity(localIntent);
    }

    public void onClickItem(String paramString) {
        this.chooseSendToAddressPopu.dismiss();
        this.goodsMsgChooseSendAddress.setText(paramString);
    }

    public void onClicktem(String paramString) {
        Log.d("aaaaaaaGoods", "item:" + paramString);
        this.chooseAddress = paramString;
        this.goodsMsgChooseSendAddress.setText(paramString);
    }

    public View onCreateView(LayoutInflater paramLayoutInflater, ViewGroup paramViewGroup, Bundle paramBundle) {
        this.view = paramLayoutInflater.inflate(R.layout.fragment_goods_msg, null, false);
        ButterKnife.bind(this, this.view);
        this.webView = ((WebView) this.view.findViewById(R.id.show_goods_detail_web));
        WebSettings webSettings = this.webView.getSettings();
        webSettings.setSaveFormData(false);
        webSettings.setLoadWithOverviewMode(true);
        webSettings.setJavaScriptEnabled(true);
        webSettings.setSupportZoom(true);
        webSettings.setUseWideViewPort(true);
        webSettings.setDomStorageEnabled(true);
        webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
        webSettings.setLoadWithOverviewMode(true);
        this.webView.setWebViewClient(new WebViewClient());
        this.webView.loadUrl("http://117.158.178.202:8001/JLMIS/junlin/mis_jsp/webview/goodsDetails.jsp?goodsId=" + this.goodsId);
        return this.view;
    }

    public void onResume() {
        super.onResume();
        this.userId = getContext().getSharedPreferences("JLAppData", 0).getInt("userId", 0);
        getGoodsDetailMsgByGoodsId();
        if (this.userId > 0) {
            buildProgressDialog();
            getShippingAddressByUserId();
        } else {
            setListener();
            this.sendToRoundGrayThree.setVisibility(View.INVISIBLE);
            this.goodsMsgChooseSendAddress.setText("暂无地址，请先登录。");
            this.goodsMsgChooseSendAddress.setOnClickListener(new OnClickListener() {
                public void onClick(View paramAnonymousView) {
                    Intent intent = new Intent(GoodsMsgFragment.this.getContext(), LoginActivity.class);
                    GoodsMsgFragment.this.startActivity(intent);
                }
            });
        }
    }

    public void paixu(List<GoodsDetailModel.ResultDataBean.GoodsEvaluationsBean> paramList) {
        ArrayList localArrayList = new ArrayList();
        if (paramList.size() > 1) {
            while (paramList.size() > 1) {
                int j = ((GoodsDetailModel.ResultDataBean.GoodsEvaluationsBean) paramList.get(0)).getEvaluationContent().length();
                int k = 0;
                int i = 0;
                while (i < paramList.size() - 1) {
                    int m = j;
                    if (j < ((GoodsDetailModel.ResultDataBean.GoodsEvaluationsBean) paramList.get(i)).getEvaluationContent().length()) {
                        m = ((GoodsDetailModel.ResultDataBean.GoodsEvaluationsBean) paramList.get(i)).getEvaluationContent().length();
                        k = i;
                    }
                    i += 1;
                    j = m;
                }
                localArrayList.add(paramList.get(k));
                paramList.remove(k);
            }
        }
    }

    public String replacePhoneNum(String paramString) {
        return paramString.substring(0, 3) + "****" + paramString.substring(7, 11);
    }

    public void setChooseAddressPopuListener() {
        this.chooseSendToAddressPopu.setOnClickItem(this);
        this.chooseSendToAddressPopu.setSetOnClickBottomOKBtn(this);
    }

    public void setChooseGoodsSpecPopuListener() {
        this.chooseGoodsSpecPopu.setOnClickAddShopCartBtnListener(this);
        this.chooseGoodsSpecPopu.setOnClickBuyNowBtnListener(this);
        this.chooseGoodsSpecPopu.setOnClickGoodsSpecItemListener(this);
    }

    public void setGoodsActivityAdapter(GoodsDetailModel.ResultDataBean paramResultDataBean, int paramInt) {
        if (this.activityList == null) {
            this.activityList = new ArrayList();
        }
        int i;
        while (paramResultDataBean.getGoodsActivitysX().size() > 0) {
            i = 0;
            while (i < paramResultDataBean.getGoodsActivitysX().size()) {
                this.activityList.add(paramResultDataBean.getGoodsActivitysX().get(i));
                i += 1;
            }
            this.activityList.clear();
        }
        if (paramResultDataBean.getGoodsSpecificationDetails().size() > 0) {
            i = 0;
            while (i < ((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) paramResultDataBean.getGoodsSpecificationDetails().get(paramInt)).getGoodsActivitys().size()) {
                this.activityList.add(((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) paramResultDataBean.getGoodsSpecificationDetails().get(paramInt)).getGoodsActivitys().get(i));
                i += 1;
            }
        }
        if (this.activityList.size() == 0) {
            GoodsActivitysBean goodsActivitysBean = new GoodsActivitysBean();
            GoodsDetailModel.ResultDataBean.GoodsActivitysBean.ActivityInformationBean localActivityInformationBean = new GoodsDetailModel.ResultDataBean.GoodsActivitysBean.ActivityInformationBean();
            localActivityInformationBean.setNameX("暂无优惠");
            goodsActivitysBean.setActivityInformation(localActivityInformationBean);
            this.activityList.add(goodsActivitysBean);
        }
        this.goodsMsgActivityRecyclerView.setLayoutManager(new CustomLanearLayoutManager(getActivity(), false));
        this.goodsMsgActivityAdapter = new GoodsMsgActivityAdapter(2131361954, this.activityList);
        this.goodsMsgActivityRecyclerView.setAdapter(this.goodsMsgActivityAdapter);
    }

    public void setListener() {
        this.goodsMsgChooseSpecBtn.setOnClickListener(this);
        this.sendToRoundGrayThree.setOnClickListener(this);
        this.goodsMsgCheckedLookDetail.setOnClickListener(this);
        this.goodsMsgCheckedLookAllEvaluation.setOnClickListener(this);
    }

    public static abstract interface SetOnClickLookGoodsSpec {
        public abstract void onClickLookGoodsSpec();
    }
}


/* Location:              /Users/davidzhang/Documents/decompileApk/jlfood-dex2jar.jar!/com/jl/jlapp/mvp/fragment/GoodsMsgFragment.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */